
'use strict'

const { Sequelize, DBPool } = require('./mysqldb')

const KnightNotice = function() {
  return DBPool.define(
    'notice',
    {
      title: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: '',
        length: 255
      },
      content: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: '',
        length: 5120
      },
      range: {
        type: Sequelize.TINYINT,
        allowNull: false,
        defaultValue: 0
      },
      status: {
        type: Sequelize.TINYINT,
        allowNull: false,
        defaultValue: 0
      },
      username: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: '',
        length: 255
      }
    },
    {
      tableName: 'notice',
      timestamps: true
    }
  )
}

const KnightNoticeUserList = function() {
  return DBPool.define(
    'notice_user_list',
    {
      notice_id: {
        type: Sequelize.INTEGER,
        allowNull: false,
        defaultValue: 0
      },
      uid: {
        type: Sequelize.BIGINT,
        allowNull: false,
        defaultValue: 0
      },
      nickname: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: '',
        length: 255
      }
    },
    {
      tableName: 'notice_user_list',
      timestamps: true
    }
  )
}

const TableKnightNotice = new KnightNotice()
const TableKnightNoticeUserList = new KnightNoticeUserList()

module.exports = {
  TableKnightNotice,
  TableKnightNoticeUserList
}
